{"path":"src/app/product/[id]/reviews/page.tsx","size":4152,"locked":false,"binary":false,"truncated":false,"content":"import { createClient } from \"@/lib/supabase/server\";\nimport { brandConfig as staticBrand } from \"@/lib/brand\";\nimport { Header } from \"@/components/Header\";\nimport Link from \"next/link\";\nimport { Star } from \"lucide-react\";\nimport { notFound } from \"next/navigation\";\n\nexport const dynamic = \"force-dynamic\";\n\nexport default async function ProductReviewsPage({\n  params,\n}: {\n  params: { id: string };\n}) {\n  let product: any = null;\n  let reviews: any[] = [];\n  let brand: any = { ...staticBrand };\n\n  if (\n    process.env.NEXT_PUBLIC_SUPABASE_URL &&\n    process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY\n  ) {\n    const supabase = await createClient();\n    if (supabase) {\n      const [productRes, reviewsRes, settingsRes] = await Promise.all([\n        supabase.from(\"products\").select(\"*\").eq(\"id\", params.id).single(),\n        supabase\n          .from(\"reviews\")\n          .select(\"id, rating, comment, author, created_at\")\n          .eq(\"product_id\", params.id)\n          .eq(\"approved\", true)\n          .order(\"created_at\", { ascending: false }),\n        supabase.from(\"site_settings\").select(\"*\").single(),\n      ]);\n\n      if (productRes.data) product = productRes.data;\n      if (reviewsRes.data) reviews = reviewsRes.data;\n      if (settingsRes.data) {\n        brand = { ...brand, ...settingsRes.data };\n      }\n    }\n  }\n\n  if (!product) notFound();\n\n  const name = brand.name || staticBrand.name;\n  const nav = brand.nav || [];\n\n  return (\n    <div className=\"min-h-screen bg-[#fafafa] font-sans antialiased text-[#111]\">\n      <Header nav={nav} name={name} />\n\n      <main className=\"mx-auto max-w-7xl px-4 md:px-6 py-12 md:py-20\">\n        <div className=\"border-b border-neutral-200 pb-5 mb-10\">\n          <span className=\"text-[10px] md:text-xs tracking-widest text-neutral-400 uppercase font-medium\">\n            Product Reviews\n          </span>\n          <h1 className=\"font-serif text-xl md:text-3xl font-medium tracking-wide mt-1\">\n            {product.name}\n          </h1>\n          <p className=\"text-sm text-neutral-500 mt-2 max-w-xl\">\n            See what others are saying about this product.\n          </p>\n        </div>\n\n        {reviews.length === 0 ? (\n          <div className=\"text-center py-20 text-neutral-400 text-sm\">\n            No reviews yet for this product.\n          </div>\n        ) : (\n          <div className=\"space-y-4 max-w-4xl\">\n            {reviews.map((review: any) => (\n              <div\n                key={review.id}\n                className=\"bg-white border border-neutral-100 p-5 rounded-sm flex flex-col gap-2 hover:border-neutral-200 transition\"\n              >\n                <div className=\"flex items-center gap-2\">\n                  <span className=\"text-xs font-medium text-neutral-900\">\n                    {review.author || \"Anonymous\"}\n                  </span>\n                  <div className=\"flex text-yellow-500 gap-0.5\">\n                    {Array.from({ length: 5 }, (_, i) => (\n                      <Star\n                        key={i}\n                        className={`w-3 h-3 ${\n                          i < review.rating\n                            ? \"fill-current stroke-none\"\n                            : \"stroke-[1.5] fill-none\"\n                        }`}\n                      />\n                    ))}\n                  </div>\n                  <span className=\"text-[10px] text-neutral-400 ml-auto\">\n                    {new Date(review.created_at).toLocaleDateString()}\n                  </span>\n                </div>\n                <p className=\"text-[12px] text-neutral-600 font-light leading-relaxed\">\n                  {review.comment}\n                </p>\n              </div>\n            ))}\n          </div>\n        )}\n\n        <div className=\"mt-10 text-center\">\n          <Link\n            href={`/review?product=${encodeURIComponent(product.name)}&product_id=${params.id}`}\n            className=\"inline-block bg-black text-white text-[11px] uppercase tracking-[0.15em] font-medium px-6 py-3.5 rounded-sm hover:bg-neutral-800 transition\"\n          >\n            Write a Review\n          </Link>\n        </div>\n      </main>\n    </div>\n  );\n        }\n"}